<template>
  <div class="user">
    <div class="title">
      <span class="word">管理员信息</span>
    </div>
    <div class="line"></div>
    <div class="middle">
      <div>
        <el-input
          v-model="input3"
          class="w-50 m-2"
          size="small"
          placeholder="请输入姓名、手机号、邮箱搜索"
          :suffix-icon="Search"
        />
      </div>
      <div class="topBtn">
        <el-button @click="adduser = true">新建账户</el-button>
        <el-button>批量删除</el-button>
      </div>
    </div>
    <div class="table">
      <el-table
        :data="tableData"
        style="width: 100%"
        border="true"
        :header-cell-style="{
          background: '#b4c7e7',
          color: 'black',
          fontSize: '12px',
          fontWeight: '500',
          textAlign:'center'
        }"
         
      >
        <el-table-column type="selection" align='center'/>
        <el-table-column prop="num" label="员工工号" align='center' />
        <el-table-column prop="name" label="姓名" align="center" />
        <el-table-column prop="email" label="邮箱" align="center" />
        <el-table-column prop="phone" label="手机号" align="center" />
        <el-table-column prop="role" label="角色" align="center" />
        <el-table-column label="项目绑定" align="center">
          <el-button type="text" @click="binds = true" align="center">绑定</el-button>
        </el-table-column>
        <el-table-column prop="status" label="状态" align="center">
          <template v-slot="scope">
            <el-switch v-model="scope.statue" />
          </template>
        </el-table-column>
        <el-table-column
          prop="createtime"
          label="创建时间 "
          header-align="center"
        />
        <el-table-column label="操作" align="center">
          <template v-slot="scope">
            <el-button
              type="text"
              class="btn"
              @click="handleCheck(scope.row), (checkUser = true)"
              >查看</el-button
            >
            <el-button
              type="text"
              class="btn"
              @click="handleEdit(scope.row), (edit = true)"
              >编辑</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 新增账户 -->
    <div class="addUserDialog addDialog">
      <el-dialog v-model="adduser" title="新建账户">
        <div class="line3"></div>

        <el-form :model="form">
          <el-form-item label="员工号" :label-width="formLabelWidth">
            <span class="num">0021</span>
          </el-form-item>
          <el-form-item label="姓名" :label-width="formLabelWidth">
            <el-input
              v-model="form.name"
              autocomplete="off"
              placeholder="请输入姓名"
            />
          </el-form-item>
          <el-form-item label="邮箱" :label-width="formLabelWidth">
            <el-input
              v-model="form.email"
              autocomplete="off"
              placeholder="请输入邮箱"
            />
          </el-form-item>
          <el-form-item label="手机号" :label-width="formLabelWidth">
            <el-input
              v-model="form.phone"
              autocomplete="off"
              placeholder="请输入手机号"
            />
          </el-form-item>
          <el-form-item label="角色" :label-width="formLabelWidth">
            <el-select
              v-model="form.role"
              class="m-2"
              placeholder="请输入角色"
              size="small"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="状态" :label-width="formLabelWidth">
            <el-switch v-model="form.statue" />
          </el-form-item>
        </el-form>
        <div class="line"></div>

        <template #footer>
          <span class="dialog-footer">
            <el-button
              @click="(dialogFormVisible = false), (cpwd = false)"
              class="cancel"
              >取消</el-button
            >
            <el-button
              type="primary"
              @click="(dialogFormVisible = false), (cpwd = false)"
              class="save"
              >保存</el-button
            >
          </span>
        </template>
      </el-dialog>
    </div>
    <!-- 绑定项目 -->
    <div class="binduserDialog bindDialog">
      <el-dialog v-model="binds" title="绑定项目">
        <div class="line3"></div>
        <div class="table2">
          <el-table
            :data="
              tableDatas.slice(
                (currentPage - 1) * pagesize,
                currentPage * pagesize
              )
            "
            style="width: 100%"
          >
            <el-table-column type="selection" />
            <el-table-column prop="Pname" label="项目名称" align="center"/>
            <el-table-column prop="city" label="城市/省份" align="center"/>
            <el-table-column prop="fun" label="功能" align="center"/>
            <el-table-column prop="owner" label="业主名称" align="center"/>
            <el-table-column prop="allCount" label="总点数" align="center"/>
            <el-table-column prop="onlineTime" label="上线时间" align="center"/>
          </el-table>
        </div>
        <div class="page">
          <div class="example-pagination-block">
            <el-pagination
              layout="prev,pager,next"
              :total="tableData.length"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
            />
          </div>
        </div>

        <div class="line"></div>

        <template #footer>
          <span class="dialog-footer">
            <el-button @click="(binds = false), (cpwd = false)" class="cancel"
              >取消</el-button
            >
            <el-button
              type="primary"
              @click="(binds = false), (cpwd = false)"
              class="save"
              >保存</el-button
            >
          </span>
        </template>
      </el-dialog>
    </div>
    <!-- 查看 -->
    <div class="checkuserDialog checkDialog">
      <el-dialog v-model="checkUser" title="查看账户">
        <div class="line3"></div>
        <div class="contant">
          <el-row :gutter="16">
            <el-col :span="6">
              <span>员工工号：0021</span>
            </el-col>
            <el-col :span="6">
              <span>姓名：张三</span>
            </el-col>
            <el-col :span="6">
              <span>邮箱:123456789@qq.com</span>
            </el-col>
          </el-row>
          <el-row :gutter="16">
            <el-col :span="6">
              <span>手机号：12345678934</span>
            </el-col>
            <el-col :span="6">
              <span>角色：设备管理员</span>
            </el-col>
            <el-col :span="6">
              <span>状态：启用</span>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <span>已绑定项目</span>
            </el-col>
          </el-row>
        </div>
        <div class="table2">
          <el-table :data="tableDatas" style="width: 100%">
            <el-table-column prop="Pname" label="项目名称" align="center"/>
            <el-table-column prop="city" label="城市/省份" align="center"/>
            <el-table-column prop="fun" label="功能" align="center"/>
            <el-table-column prop="owner" label="业主名称" align="center"/>
            <el-table-column prop="allCount" label="总点数" align="center"/>
            <el-table-column prop="onlineTime" label="上线时间" align="center"/>
          </el-table>
        </div>
      </el-dialog>
    </div>
    <!-- 编辑 -->
    <div class="checkuserDialog checkDialog">
      <el-dialog v-model="edit" title="编辑账户">
        <div class="line3"></div>
        <div class="contant">
          <el-row :gutter="24">
            <el-col :span="6">
              <span>员工工号：0021</span>
            </el-col>
            <el-col :span="6">
              <div class="box">
                <div class="word">姓名:</div>
                <el-input></el-input>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="box">
                <div class="word">邮箱:</div>
                <el-input></el-input>
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="16">
            <el-col :span="6">
              <div class="box">
                <div class="word">手机号：</div>
                <el-input></el-input>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="box">
                <div class="word">角色：</div>

                <el-select
                  v-model="value"
                  class="m-2"
                  placeholder="Select"
                  size="small"
                >
                  <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </div>
            </el-col>
            <el-col :span="6">
              <div class="box">
                <div class="word">状态：</div>
                <el-switch v-model="value1" />
              </div>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="21">
              <span>已绑定项目</span>
              <el-button class="bd" @click="bindlog">绑定</el-button>
            </el-col>
          </el-row>
        </div>
        <div class="table2">
          <el-table :data="tableDatas" style="width: 100%">
            <el-table-column prop="Pname" label="项目名称" align="center"/>
            <el-table-column prop="city" label="城市/省份" align="center"/>
            <el-table-column prop="fun" label="功能" align="center"/>
            <el-table-column prop="owner" label="业主名称" align="center"/>
            <el-table-column prop="allCount" label="总点数" align="center"/>
            <el-table-column prop="onlineTime" label="上线时间" align="center"/>
            <el-table-column label="操作">
              <template #default>
                <el-button link type="text" size="small" class="btn">移除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref } from "vue";
var currentPage = ref(1);
var pagesize = ref(10);
const value1 = ref(true);
const adduser = ref(false);
const checkUser = ref(false);
const edit = ref(false);
const binds = ref(false);
const formLabelWidth = ref(70);
import { Search } from "@element-plus/icons-vue";
const tableDatas = reactive([
  {
    Pname: "某某项目",
    city: "北京",
    fun: "酒店",
    owner: "张三",
    allCount: "123",
    onlineTime: "2022年1月",
  },
  {
    Pname: "某某项目",
    city: "北京",
    fun: "酒店",
    owner: "张三",
    allCount: "123",
    onlineTime: "2022年1月",
  },
  {
    Pname: "某某项目",
    city: "北京",
    fun: "酒店",
    owner: "张三",
    allCount: "123",
    onlineTime: "2022年1月",
  },
  {
    Pname: "某某项目",
    city: "北京",
    fun: "酒店",
    owner: "张三",
    allCount: "123",
    onlineTime: "2022年1月",
  },
]);
const tableData = reactive([
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
  {
    num: "001",
    name: "Tom",
    email: "12334534@163.com",
    phone: "13549294050",
    role: "业主管理员",
    status: false,
    createtime: "2022-01- 12:00:00",
  },
]);
function handleEdit(b) {
  console.log(b);
}
function handleCheck(a) {
  console.log(a);
}
function bindlog() {
  edit.value = false;
  binds.value = true;
}
const form = reactive({
  name: "",
  email: "",
  phone: "",
  role: "",
  statue: "",
});
</script>

<style scoped lang="less">
.topBtn {
  .el-button {
    left: 1592px;
    top: 201px;
    width: 104px;
    height: 30px;
    line-height: 20px;
    border-radius: 4px;
    background-color: rgba(143, 170, 220, 100);
    text-align: center;
    color: white;
    border: none;
  }
}
.bd {
  left: 766px;
  top: 469px;
  width: 80px;
  height: 24px;
  line-height: 20px;
  border-radius: 4px;
  background-color: rgba(143, 170, 220, 100);
  text-align: center;
  margin-left: 20px;
  color: white;
  border: none;
}
.word {
  width: 90px;
}
.box {
  display: flex;
  /deep/ .el-input--small .el-input__inner {
    width: 120px;
    height: 24px;
    line-height: 24px;
    padding: 0 7px;
  }
}
.user {
  width: 100%;
  height: 100%;
  border-style: none;
  border-color: unset;
  box-shadow: rgb(77 98 165 / 10%) 0px 5px 20px 0px;
  border-radius: 8px;
  font-size: 14px;
  padding: 0px;
  line-height: 20px;
  font-weight: normal;
  font-style: normal;
  background-color: white;
}
.title {
  padding: 20px;
  .word {
    font-family: SourceHanSansSC;
    font-weight: 550;
    font-size: 20px;
    color: rgb(77, 98, 165);
    font-style: normal;
    letter-spacing: 2px;
    line-height: 28px;
    text-decoration: none;
  }
}
.line {
  border-bottom: 2px rgba(77, 98, 165, 0.2) solid;
}
.middle {
  display: flex;
  justify-content: flex-end;
  align-content: space-between;
  flex-direction: row;
  padding: 20px;
  .el-input {
    margin-right: 20px;
    margin-top: 5px;
  }
}
.btn {
    color: rgb(81, 99, 173);
  }
.table {
  padding: 20px;
  // text-align: center;
  .btn {
    color: rgb(81, 99, 173);
  }
}
.addDialog {
  :deep(.el-dialog__title) {
    color: rgb(81, 99, 167);
    font-size: 19px;
  }
  :deep(.el-dialog__close) {
    font-size: 27px !important;
    color: rgb(81, 99, 167);
  }
  :deep(.el-dialog__body) {
    padding: 20px 0 20px;
  }
}
.addUserDialog {
  /deep/.el-dialog {
    border-radius: 8px;
    --el-dialog-width: 410px;
    width: var(--el-dialog-width, 410px);
  }
  /deep/.el-input {
    width: 250px;
    margin-left: 30px;
  }
  .line3 {
    border-bottom: 2px rgba(77, 98, 165, 0.2) solid;
    margin-bottom: 30px;
  }
  .num {
    margin-left: 30px;
  }

  .el-switch {
    margin-left: 30px;
  }
  .cancel {
    left: 917px;
    top: 696px;
    width: 80px;
    height: 30px;
    line-height: 20px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 100);
    background-color: rgba(204, 204, 204, 100);
    text-align: center;
    border: none;
  }
  .save {
    left: 1013px;
    top: 696px;
    width: 80px;
    height: 30px;
    line-height: 20px;
    border-radius: 4px;
    background-color: rgba(143, 170, 220, 100);
    text-align: center;
    border: none;
  }
}
.bindDialog {
  :deep(.el-dialog__title) {
    color: rgb(81, 99, 167);
    font-size: 19px;
  }
  :deep(.el-dialog__close) {
    font-size: 27px !important;
    color: rgb(81, 99, 167);
  }
  :deep(.el-dialog__body) {
    padding: 20px 0 20px;
  }
}
.binduserDialog {
  /deep/.el-dialog {
    border-radius: 8px;
    --el-dialog-width: 729px;
    width: var(--el-dialog-width, 729px);
  }
  .page {
    display: flex;
    justify-content: flex-end;
  }
  .line3 {
    border-bottom: 2px rgba(77, 98, 165, 0.2) solid;
    margin-bottom: 10px;
  }
  .num {
    margin-left: 30px;
  }
  .table2 {
    padding: 10px 20px 10px 20px;
  }

  .cancel {
    left: 917px;
    top: 696px;
    width: 80px;
    height: 30px;
    line-height: 20px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 100);
    background-color: rgba(204, 204, 204, 100);
    text-align: center;
    border: none;
  }
  .save {
    left: 1013px;
    top: 696px;
    width: 80px;
    height: 30px;
    line-height: 20px;
    border-radius: 4px;
    background-color: rgba(143, 170, 220, 100);
    text-align: center;
    border: none;
  }
}
.checkDialog {
  :deep(.el-dialog__title) {
    color: rgb(81, 99, 167);
    font-size: 19px;
  }
  :deep(.el-dialog__close) {
    font-size: 27px !important;
    color: rgb(81, 99, 167);
  }
  :deep(.el-dialog__body) {
    padding: 20px 0 20px;
  }
}
.checkuserDialog {
  background-color: crimson;
  /deep/.el-dialog {
    border-radius: 8px;
    --el-dialog-width: 729px;
    width: var(--el-dialog-width, 729px);
  }

  .line3 {
    border-bottom: 2px rgba(77, 98, 165, 0.2) solid;
    margin-bottom: 30px;
  }
  .num {
    margin-left: 30px;
  }
  .table2 {
    padding: 10px 20px 10px 20px;
  }
}
.contant .el-row {
  display: flex;
  flex-wrap: wrap;
  position: relative;
  box-sizing: border-box;
  justify-content: space-evenly;
  margin-bottom: 10px;
  span {
    color: rgba(127, 127, 127, 100);
    font-size: 14px;
    text-align: left;
    font-family: SourceHanSansSC-regular;
  }
}
</style>
<style scoped lang="less">
/deep/.el-input--small .el-input__suffix {
  left: 270px;
}
/deep/.el-input--small .el-input__inner {
  width: 290px;
  height: 24px;
  line-height: 24px;
  padding: 0 7px;
}
/deep/.el-table .el-table__cell {
  background-color: rgb(245, 248, 251);
  padding: 8px 0;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
  text-align: left;
  z-index: 1;
}
</style>
